#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#include "initexts.h"
 
 
#ifndef USE_GLEW
PFNGLGENBUFFERSARBPROC glGenBuffers;
#endif

GLenum InitExtensions()
{
    GLenum code = 0;
    
    #ifndef USE_GLEW
    /* chargement des fonctions d'extension(s) */
    glGenBuffers = SDL_GL_GetProcAddress("glGenBuffersARB");
    #else
    /* initialisation de GLEW */
    code = glewInit();
    if(code != GLEW_OK)
    {
        fprintf(stderr, "impossible d'initialiser les extensions"
                        " avec GLEW : %s\n", glewGetErrorString(code));
        code = 1;
    }
    else
        code = 0;
    #endif
    
    return (code);
}

glGenBuffers = SDL_GL_GetProcAddress("glGenBuffersARB");
glNomPointeur = SDL_GL_GetProcAddress("glNomFonction");
/* etc ... */

int CheckExtension(const char *name)
{
    #ifndef USE_GLEW
    const unsigned char *exts = glGetString(GL_EXTENSIONS);
    
    if(strstr((const char*)exts, name) == NULL)
    #else
    if(!glewIsSupported(name))
    #endif
    {
        fprintf(stderr, "extension '%s' non supportee\n", name);
        return 0;
    }
    else
        return 1;
}
